package cn.ikun.dcx;

import cn.ikun.dcx.User;
import org.apache.commons.lang3.RandomStringUtils;

import java.lang.reflect.Method;

public class dcxapp {
    public static void main( String[] args) throws  Exception {
        //
        //
        //String s = RandomStringUtils.randomAlphabetic(6);
        //System.out.println(s);

        //创建 User 类的实例
        User u = new User();
        //为实例u的name属性赋值为Timor
        u.setName("ggdog");
        System.out.println(u.getName());

        //创建age实例

        u.setAge(20);
        System.out.println(u.getAge());


        Class<?> UU = Class.forName("cn.ikun.dcx.User");
        Object o = UU.newInstance();

        Method setName = UU.getMethod("setName",String.class);
        setName.invoke(o,"dcxddd");

        Method getName = UU.getMethod("getName");
        Object result = getName.invoke(o);
        System.out.println(result);

        Method setAge = UU.getMethod("setAge", Integer.class);
        setAge.invoke(o,19);
        Method getAge = UU.getMethod("getAge");
        Object result2 = getAge.invoke(o);
        System.out.println(result2);

    }
}